#pragma once
#include "stdafx.h"
#include <boost/shared_ptr.hpp>
#include "StreamPage.h"
#include "BufferConstraint.h"
#include "Element.h"
#include "AbstractBuffer.h"
/* a buffer to saves the lineage information 
   something insert into this buffer is a combination of (lineage, element)
   indicates that the document ids in the lineage contributes to the element 
   Later, some one can use lineage to search for element
*/
class LineageBuffer:public AbstractBuffer
{
private:

	
	const int lineageNumber; // the number of lineage document in one record.
	MemoryPosition freePositionHead;  //the head memory position of free memory chunks
	
	// map the lineage to memory position, it is used to search the element by lineage easily
	std::map<Lineage, MemoryPosition>lineagePositionMap; 
	

public:
	LineageBuffer( int lineageNumber);
	~LineageBuffer(void);
	void insertLineage(Lineage& lineage,Element& outputElement);
    bool getAndDeleteElement(Lineage& lineage, Element& outputElement);
	bool isFull(void);
};

